<template>
  <div>
    <div class="base_form" style="padding-top: 15px;margin: auto;min-height: 100vh;">
      <div class="base_query_oneLine">

        <div class="query_left">
          <el-button class="commButton" size="small" @click="mission()">发布互评任务
          </el-button>
        </div>
        <div class="query_left">
          <el-button class="commButton" size="small" @click="missionCancel()">结束互评任务
          </el-button>
        </div>
        <div class="query_right">
          <el-input class="marginl" placeholder="请输入学号或姓名" v-model="numName" style="width: 300px; margin-right: 5px" />
          <el-button class="blueButton" size="small" @click="doQuery()">查询
          </el-button>
        </div>
      </div>
      <div class="table_center">
        <el-table :data="dataList" border style="width: 100%">

          <el-table-column prop="num" label="学号" sortable> </el-table-column>

          <el-table-column prop="name" label="姓名"></el-table-column>
          <el-table-column prop="name2" label="评价者"></el-table-column>
          <!-- 这是一段注释内容<el-table-column prop="tag" label="标签"></el-table-column> -->
          <el-table-column prop="assessment" label="评语" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="morality" label="品行">
            <template #default="props">
              <el-rate v-model=props.row.morality disabled :colors="colors">
              </el-rate>
            </template>
          </el-table-column>
          <el-table-column prop="talent" label="才华">
            <template #default="props">
              <el-rate v-model=props.row.talent disabled :colors="colors">
              </el-rate>
            </template>
          </el-table-column>

          <el-table-column prop="whole" label="总体评价">
            <template #default="props">
              <el-rate v-model=props.row.whole disabled :colors="colors">
              </el-rate>
            </template>
          </el-table-column>

          <el-table-column label="操作" width="200" align="center" color="black">
            <template v-slot="scope">
              <!--            <el-button-->
              <!--                class="table_edit_button"-->
              <!--                @click="doEdit(scope.row.id)"-->
              <!--                size="mini"-->
              <!--            >编辑</el-button-->
              <!--            >-->
              <el-button class="table_delete_button" style="margin-left: 5px" @click="deleteRow(scope.row.assessmentId)">删除
              </el-button>
            </template>
          </el-table-column>

        </el-table>
      </div>
    </div>
  </div>
</template>







<script lang="ts">
import { getDictionaryOptionItemList } from "~/services/systemServ";
import { getStudentInfo, studentEditSave } from "~/services/personServ";
import { defineComponent } from "vue";
import { message, messageConform } from '~/tools/messageBox'
import router from "~/router";
import { type OptionItem, type StudentItem } from "~/models/general";
import { getOptionItem } from "~/tools/comMethod";
import { formatDate } from "~/tools/comMethod";
import { assessmentInit, assessmentQuery, assessmentDelete, assessmentMission, assessmentCancel } from "~/services/teachingServ";
import { id } from "element-plus/es/locale";

export default defineComponent({
  //数据
  data() {
    return {
      colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
      numName: '',
      dataList: [],
    };
  },


  //页面加载方法, 获取性别选择列表,获取学生信息,注意async和await的使用
  created() {
    this.assessmentInit();
  },

  methods: {
    async assessmentInit() {
      this.dataList = (await assessmentInit()).data;
      //console.log(this.dataList);
    },

    doQuery() {
      assessmentQuery(this.numName).then((res) => {
        if (res.code === 0) {
          this.dataList = res.data;
        } else {
          message(this, res.msg)
        }
      });
    },

    mission() {
      assessmentMission().then((res) => {
        if (res.code === 0) {
          this.dataList = res.data;
          message(this, "发布任务成功")
        } else {
          message(this, res.msg)
        }
      });
    },

    missionCancel() {
      assessmentCancel().then((res) => {
        if (res.code === 0) {
          this.dataList = res.data;
          message(this, "结束任务成功")
        } else {
          message(this, res.msg)
        }
      })
    },
    deleteRow(assessmentId:number ) {
      assessmentDelete(assessmentId).then((res)=>{
        if(res.code === 0){
          this.doQuery();
        }
        else{
          message(this,res.msg)
        }
      })
    },
  },
});
</script>



<style></style>
